//计算小费
import { Behaviour } from "../engine/Behaviour";
import { getGameObjectById } from "../engine";
import { TextRenderer } from "../engine/TextRenderer";
import { BitmapRenderer } from "../engine/BitmapRenderer";

export class Tip extends Behaviour{

    satiNumForTip:number
    //satiNum:number
    tip:number = 0
    str:string
    //满意度减减的flag，传给system里面
    startSati:boolean
    //是否重置
    reset:boolean
    //是否上菜了
    giveToGuest:boolean
    //是否要获得小费
    getTip:boolean = false

    onStart(){
        //this.zhongzhuan()
    }

    // zhongzhuan(){
    //     setTimeout(() => {
    //         if(this.getTip){
    //             this.randomTip()
    //             this.getTip = false
    //             return 234
    //         }
    //         this.zhongzhuan()
    //     }, 1);
    // }

     randomTip(){
        this.str = getGameObjectById('UI_satisfaction_text').getBehaviour(TextRenderer).text
        this.satiNumForTip = Number(this.str)

        if(this.satiNumForTip > 75){
            this.tip = Math.random() + 4
        }else if(this.satiNumForTip > 50){
            this.tip = Math.random() + 2
        }else{
            this.tip = Math.random()
        } 
        console.log("小费：" + this.tip.toFixed(2))    
        return this.tip
    }
}
